# -*- coding: utf-8 -*-
# @Time    : 2018/8/15 13:59
# @Author  : 聂家利
# @Email   : 1073438012@qq.com
# @File    : mainDialog.py
# @Software: PyCharm

from .import *
from its_auth.lib import _get_maya_main_windowsdow
from centerUi import center_ui


class mainDialog(QtWidgets.QDialog):

    def __init__(self, parent=None):
        super(mainDialog, self).__init__(_get_maya_main_windowsdow())
        self.setWindowTitle(u'权限测试')
        self.resize(400, 200)
        main_layout = QtWidgets.QVBoxLayout(self)
        self.result_label = QtWidgets.QLabel(u"<div align=center>权限测试</div>")
        self.result_label.setFrameStyle(QtWidgets.QFrame.Panel | QtWidgets.QFrame.Sunken)
        main_layout.addWidget(self.result_label)
        self.scrollWidget = QtWidgets.QWidget()
        self.scrollWidget.setSizePolicy(QtWidgets.QSizePolicy.Maximum, QtWidgets.QSizePolicy.Maximum)
        self.scrollLayout = QtWidgets.QVBoxLayout(self.scrollWidget)
        self.scrollarea = QtWidgets.QScrollArea()
        self.scrollarea.setWidgetResizable(True)
        centerui = center_ui()
        self.scrollarea.setWidget(centerui)
        main_layout.addWidget(self.scrollarea)
        self.button_box = QtWidgets.QDialogButtonBox(QtWidgets.QDialogButtonBox.Ok |
                                                     QtWidgets.QDialogButtonBox.Cancel)
        main_layout.addWidget(self.button_box)
        self.button_box.accepted.connect(self.button_cancel)
        self.button_box.rejected.connect(self.reject)

    def closeEvent(self, event):
        reply = QtWidgets.QMessageBox.question(self, u"退出", u"确认退出吗？", QtWidgets.QMessageBox.Yes,
                                               QtWidgets.QMessageBox.No)
        if reply == QtWidgets.QMessageBox.Yes:
            event.accept()
        else:
            event.ignore()

    def reject(self):
        QtWidgets.QDialog.accept(self)

    def button_cancel(self):
        print("not write")


